package com.example.myapplication;


import android.annotation.SuppressLint;
import android.os.Bundle;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import java.util.List;

public class MainActivity_DB extends AppCompatActivity {

    private TextView resultTextView;
    private RateManager rateManager;

    @SuppressLint("MissingInflatedId")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        resultTextView = findViewById(R.id.resultTextView);
        rateManager = new RateManager(this);
        loadExchangeRates();
    }

    private void loadExchangeRates() {
        List<ExchangeRateItem> rates = rateManager.getExchangeRates();
        StringBuilder result = new StringBuilder();
        for (ExchangeRateItem rate : rates) {
            result.append(rate.getCurrencyName())
                    .append(": ")
                    .append(rate.getExchangeRate())
                    .append("\n");
        }
        resultTextView.setText(result.toString());
    }
}